﻿using System.Collections.Generic;
using System.ComponentModel.Composition;

namespace GlobalOfficeTools.Framework.CacheService
{
    [PartCreationPolicy(CreationPolicy.Shared)]
    [Export(typeof(ICacheService))]
    public class CacheService : ICacheService
    {
        #region Private Fields 
        private Dictionary<string, object> _cache;
        #endregion

        #region Constructor 
        public CacheService() 
        {
            _cache = new Dictionary<string, object>();
        }
        #endregion

        #region Public Methods 
        public void AddCache(string objectName, object values)
        {
            if (_cache.ContainsKey(objectName)) _cache.Remove(objectName);
            _cache.Add(objectName, values);
        }
        public object GetFromCache(string objectName) 
        {
            if (_cache.ContainsKey(objectName)) return _cache[objectName];
            else return null;
        }
        #endregion
    }
}
